//
//  HXCatagoryCollectionViewCell.m
//  GiftSay
//
//  Created by laohu on 16/1/9.
//  Copyright © 2016年 liyinkai. All rights reserved.
//

#import "HXCatagoryCollectionViewCell.h"
#import "HXLabelVerticalAlignment.h"
@implementation HXCatagoryCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)setModel:(HXCatagorySecondModel *)model {
    _model = model;
    [self.image setImageWithURL:[NSURL URLWithString:_model.icon_url] placeholder:nil];
    self.label.text = _model.name;
    
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    self.image.frame = CGRectMake(0, 0, self.width, self.width);
    self.label.frame = CGRectMake(0, self.image.bottom, self.width, self.height - self.width);
}

- (void)createView {
    self.image = [[UIImageView alloc] initWithFrame:CGRectZero];
    self.image.layer.cornerRadius = self.width / 2;
//    self.image.backgroundColor = [UIColor greenColor];
    [self addSubview:_image];
    
    self.label = [[HXLabelVerticalAlignment alloc] initWithFrame:CGRectZero];
    [self.label setVerticalAlignment:VerticalAlignmentTop];
    self.label.font = [UIFont systemFontOfSize:13 * SCREEN_WIDTH];
//    self.label.backgroundColor = [UIColor yellowColor];
    self.label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_label];
    
}
@end
